package cn.zc.tools.security.config;

import cn.zc.tools.security.filter.CurriculumSecurityFilter;
import cn.zc.tools.security.filter.StudentSecurityFilter;
import cn.zc.tools.security.utils.SecurityUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

public class SecurityFilterConfiguration {
    /**
     * 创建一个studentFilter，加上@ConditionalOnMissingBean防止spring中创建多个相同的bean，毕竟
     * 我们打算每个包都应该有自己独立的filter拦截器
     * @return
     */
    @ConditionalOnMissingBean
    @Bean
    public StudentSecurityFilter getStudentSecurityFilter(){
        return new StudentSecurityFilter();
    }

    /**
     * 课程包拦截器
     * @return
     */
    @ConditionalOnMissingBean
    @Bean
    public CurriculumSecurityFilter getCurriculumSecurityFilter(){
        return new CurriculumSecurityFilter();
    }



    /**
     * 用于获取用户信息的类
     * @return
     */
    @Bean
    public SecurityUtils getSecurityUtils(){
        return new SecurityUtils();
    }
}
